#!/usr/bin/env python

import logging

from google.appengine.ext import webapp, db
from google.appengine.ext.webapp.util import run_wsgi_app

from plugins import *
import rss

class MainPage(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/html; charset=utf-8'
        self.response.out.write('It works!')
        
class NotFoundPage(webapp.RequestHandler):
    def get(self):
        self.error(404)
        self.response.out.write('Opps, wrong url?')
        
class EchoService(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
        self.response.out.write(self.request.remote_addr)

application = webapp.WSGIApplication([
    (r'/', MainPage),
    (r'/douban/$', douban.Dispatcher),
    (r'/fanfou/$', fanfou.Dispatcher),
    (r'/pingfm/(.*)$', pingfm.Dispatcher),
    (r'/rss/$', rss.Dispatcher),
    (r'/echo/$', EchoService),
    (r'/.*', NotFoundPage),
], debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()